﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace HomeWork1_2
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void op_SelectedIndexChanged(object sender, EventArgs e)
        {
          
        }

        private void calculate_Click(object sender, EventArgs e)
        {
            try
            {
                double number1 = Convert.ToDouble(num1.Text);
                double number2 = Convert.ToDouble(num2.Text);
                switch (op.Text)
                {
                    case "+":
                        result.Text = Convert.ToString(number1 + number2);
                        break;
                    case "-":
                        result.Text = Convert.ToString(number1 - number2);
                        break;
                    case "*":
                        result.Text = Convert.ToString(number1 * number2);
                        break;
                    case "/":
                        result.Text = Convert.ToString(number1 / number2);
                        break;
                }
            }
            catch (FormatException)
            {
                result.Text = "输入正确的数";
            }
        }
    }
}
